package edu.nf.db.util.result;

import edu.nf.db.util.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhu
 * @date 2024-05-08
 */
public abstract class AbstractListHandler<T> implements ResultSetHandler<List<T>> {
    @Override
    public List<T> handle(ResultSet rs) throws SQLException {
        List<T> list = new ArrayList<T>();
        while (rs.next()) {
            list.add(handleRow(rs));
        }
        return list;
    }

    public abstract T handleRow(ResultSet rs) throws SQLException;
}
